<?php
class OtherservicesController extends AppController {

	var $name = 'Otherservices';

	function beforeFilter() {
    parent::BeforeFilter();   	
	//$this->Auth->allow('login','logout','userlist','add','confirmaccount');
	//$this->Auth->allow('*');
}

        function index() {
		$this->Otherservice->recursive = 0;
		$this->set('otherservices', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid otherservice', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('otherservice', $this->Otherservice->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
                    $this->data['Otherservice']['user_id'] = $this->Auth->user('id');
			$this->Otherservice->create();
			if ($this->Otherservice->save($this->data)) {
				$this->Session->setFlash(__('The otherservice has been saved', true));
				$this->redirect(array('controller' => 'uinformations','action' => 'view'));
			} else {
				$this->Session->setFlash(__('The otherservice could not be saved. Please, try again.', true));
			}
		}
		$users = $this->Otherservice->User->find('list');
		$this->set(compact('users'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid otherservice', true));
			$this->redirect(array('controller' => 'uinformations','action' => 'view'));
		}
		if (!empty($this->data)) {
			if ($this->Otherservice->save($this->data)) {
				$this->Session->setFlash(__('The otherservice has been saved', true));
				$this->redirect(array('controller' => 'uinformations','action' => 'view'));
			} else {
				$this->Session->setFlash(__('The otherservice could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Otherservice->read(null, $id);
		}
		$users = $this->Otherservice->User->find('list');
		$this->set(compact('users'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for otherservice', true));
			$this->redirect(array('controller' => 'uinformations','action' => 'view'));
		}
		if ($this->Otherservice->delete($id)) {
			$this->Session->setFlash(__('Otherservice deleted', true));
			$this->redirect(array('controller' => 'uinformations','action' => 'view'));
		}
		$this->Session->setFlash(__('Otherservice was not deleted', true));
		$this->redirect(array('controller' => 'uinformations','action' => 'view'));
	}
}
?>